package com.shenyong.ladmin.service.Impl;

import com.shenyong.ladmin.mapper.Article_DianZanMapper;
import com.shenyong.ladmin.entity.Article_Dianzan;
import com.shenyong.ladmin.result.Page;
import com.shenyong.ladmin.service.Article_DianZanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Article_DianZanServiceImpl implements Article_DianZanService {
    @Autowired
    private Article_DianZanMapper article_DianZanMapper;
    @Override
    public List<Article_Dianzan> articleDianZanAll(Page page) {
        return article_DianZanMapper.articleDianZanAll(page);
    }

    @Override
    public int articleDianZanCount(Page page) {
        return article_DianZanMapper.articleDianZanCount(page);
    }

    @Override
    public int deleteDianZan(int articleclick_id) {
        return article_DianZanMapper.deleteDianZan(articleclick_id);
    }

    @Override
    public int DianAll(Article_Dianzan article_Dianzan) {
        List<Article_Dianzan> dzbd=article_DianZanMapper.DianZanAll(article_Dianzan);
        return dzbd.size();
    }

    @Override
    public int DianZanAll(Article_Dianzan article_Dianzan) {
        List<Article_Dianzan> dzbd=article_DianZanMapper.DianZanAll(article_Dianzan);
        System.out.println(dzbd);
        if(dzbd.size()==1){
            int delint=article_DianZanMapper.delDianZan(article_Dianzan);
            return 0;
        } else{
            int addint=article_DianZanMapper.AddDianZan(article_Dianzan);
            return 1;
        }

    }
}
